package com.redoor.app.stake.basicdata.controller;

import com.github.pagehelper.PageInfo;
import com.redoornetwork.framework.core.response.ResponseResult;
import com.redoornetwork.framework.core.response.ResultGenerator;
import com.yotouch.app.stake.hsf.ChargerService;
import com.yotouch.app.stake.hsf.StakeService;
import com.yotouch.app.stake.model.response.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/stakes")
@Api(value = "提供HSF桩接口API")
public class HSFStakeAPIController {

    @Autowired
    private StakeService stakeService;



    @ApiOperation(value = "sgccTotalCount", notes = "sgccTotalCount")
    @PostMapping("/constomer/sgccTotalCount")
    public ResponseResult sgccTotalCount() {
        int count = stakeService.sgccTotalCount().getValue();

        return ResultGenerator.generatorSuccess(count);
    }



    @ApiOperation(value = "sgccList", notes = "sgccList")
    @PostMapping("/constomer/sgccList")
    public ResponseResult sgccList(@RequestParam int offset, @RequestParam  int limit) {
        ResponseStakeList list = stakeService.sgccList(offset,limit);

        PageInfo pageInfo = new PageInfo(list.getStakeList());
        pageInfo.setTotal(1000);
        return ResultGenerator.generatorSuccess(pageInfo);
    }


    @ApiOperation(value = "totalCount", notes = "totalCount")
    @PostMapping("/constomer/totalCount")
    public ResponseResult totalCount() {
        ResponseInt res = stakeService.totalCount();

        return ResultGenerator.generatorSuccess(res.getValue());
    }


    @ApiOperation(value = "list", notes = "list")
    @PostMapping("/constomer/list")
    public ResponseResult list(@RequestParam int offset, @RequestParam  int limit) {
        ResponseStakeList list = stakeService.list(offset,limit);

        PageInfo pageInfo = new PageInfo(list.getStakeList());
        pageInfo.setTotal(1000);
        return ResultGenerator.generatorSuccess(pageInfo);
    }

    @ApiOperation(value = "countByStation", notes = "countByStation")
    @PostMapping("/constomer/countByStation")
    public ResponseResult countByStation(String stationUuid) {
        ResponseInt res = stakeService.countByStation(stationUuid);

        return ResultGenerator.generatorSuccess(res.getValue());
    }


    @ApiOperation(value = "listByStation", notes = "listByStation")
    @PostMapping("/constomer/listByStation")
    public ResponseResult listByStation(@RequestParam String stationUuid,@RequestParam int offset, @RequestParam  int limit) {
        ResponseStakeList list = stakeService.listByStation(stationUuid,offset,limit);

        PageInfo pageInfo = new PageInfo(list.getStakeList());
        pageInfo.setTotal(1000);
        return ResultGenerator.generatorSuccess(pageInfo);
    }

    @ApiOperation(value = "get", notes = "get")
    @PostMapping("/constomer/get")
    public ResponseResult get(@RequestParam String uuid) {
        ResponseStake stake = stakeService.get(uuid);

        return ResultGenerator.generatorSuccess(stake.getStake());
    }

    @ApiOperation(value = "getStakeByNo", notes = "getStakeByNo")
    @PostMapping("/constomer/getStakeByNo")
    public ResponseResult getStakeByNo(@RequestParam String stakeNo) {
        ResponseStake stake = stakeService.getStakeByNo(stakeNo);

        return ResultGenerator.generatorSuccess(stake.getStake());
    }

    @ApiOperation(value = "genRegisterCode", notes = "genRegisterCode")
    @PostMapping("/constomer/genRegisterCode")
    public ResponseResult getStakeByNo(int count, int type,String prOrgCode,String chargerFeeModelId,String serviceFeeModelId,
                                       String note,String orderId,String vendorName,String equipModel,String userName,String userToken) {

        ResponseBase base = stakeService.genRegisterCode(count,type,prOrgCode,chargerFeeModelId,serviceFeeModelId,note,orderId,vendorName,equipModel,userName,userToken);

        return ResultGenerator.generatorSuccess(base);
    }

}
